using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using MBMC.Paths;

namespace MBMC.Dialogs
{
    public partial class Particles : Form
    {
        string mbfolder;
        bool GIMPexist;
        Paths.Paths p = new MBMC.Paths.Paths();
        public Particles(string actualmbfolsder, bool GIMPInstalled)
        {
            InitializeComponent();
            mbfolder = actualmbfolsder;
            GIMPexist = GIMPInstalled;
        }

        private void Particles_Load(object sender, EventArgs e)
        {
            if (GIMPexist == true)
            {
                button5.Enabled = true;
            }
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(p.Vrat_Cestu(mbfolder, MBPaths.FMDParticles));
            foreach (System.IO.FileInfo file in di.GetFiles("*.png"))
            {
                Console.WriteLine("{0}, {1}, {2}", file.Name, file.Length, file.Extension);
                listBox1.Items.Add(file.Name);
            }
            foreach (System.IO.FileInfo file in di.GetFiles("*.jpg"))
            {
                Console.WriteLine("{0}, {1}, {2}", file.Name, file.Length, file.Extension);
                listBox1.Items.Add(file.Name);
            }
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string cesta = p.Vrat_Cestu(mbfolder, MBPaths.FMDParticles) + "/" + listBox1.SelectedItem.ToString();
            richTextBox1.Text = cesta;
            pictureBox1.ImageLocation = cesta;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            PrimitiveEditor pee = new PrimitiveEditor(p.Vrat_Cestu(mbfolder, MBPaths.MarbleParctileSettings));
            pee.ShowDialog();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("No GIMP plugin installed!");
            FSImage fsii = new FSImage(pictureBox1.ImageLocation.ToString());
            fsii.ShowDialog();
            fsii.SHOWABOUT();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            System.IO.File.Delete(pictureBox1.ImageLocation);
            MessageBox.Show("Particle dialog will be closed to show new updated informations:)");
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            System.IO.FileInfo fi = new System.IO.FileInfo(openFileDialog1.FileName);
            System.IO.File.Copy(openFileDialog1.FileName, p.Vrat_Cestu(mbfolder, MBPaths.FMDParticles) + "/" + fi.Name, true);
            MessageBox.Show("Particle dialog will be closed to show new updated informations:)");
            this.Close();
        }
    }
}